<template>
  <el-container>
    <el-aside :style="{width:isCollapse?'65px':'200px'}" >

      <el-menu
      router
      :style="{width:isCollapse?'65px':'200px'}"
      :collapse="isCollapse"
      collapse-transition:false
      background-color="rgb(50, 55, 68)"
      text-color="#fff"
      active-text-color="#ffd04b">
      <el-menu-item index="1" :style="{width:isCollapse?'65px':'200px'}">
        <i class="el-icon-location"></i>
        <span slot="title">首页</span>
      </el-menu-item>
      <el-submenu index="2" :style="{width:isCollapse?'65px':'200px'}">
        <template slot="title">
          <i class="el-icon-menu"></i>
          <span>内容管理</span>
        </template>
          <el-menu-item index="/articleadd" >发布文章</el-menu-item>
          <el-menu-item index="/article" >内容列表</el-menu-item>
          <el-menu-item index="2-1" >评论列表</el-menu-item>
          <el-menu-item index="2-2">素材列表</el-menu-item>
        </el-submenu>
      <el-menu-item index="3" :style="{width:isCollapse?'65px':'200px'}">
        <i class="el-icon-location"></i>
        <span slot="title">粉丝管理</span>
      </el-menu-item>
      <el-menu-item index="/account" :style="{width:isCollapse?'65px':'200px'}">
        <i class="el-icon-location"></i>
        <span slot="title">账户管理</span>
      </el-menu-item>
      </el-menu>
    </el-aside>
    <el-container>
      <el-header >
        <div id="left" >
          <i class="el-icon-s-fold" @click="shou()"></i>
          <span>江苏传智播客教育科技股份有限公司</span>
        </div>
        <div id="right">
          <el-input placeholder="请输入搜索的文章内容" prefix-icon="el-icon-search" type="text"></el-input>
          <span style="padding:0 40px">消息</span>
          <el-dropdown>

            <span class="el-dropdown-link">

               <el-avatar :src="user.photo"></el-avatar>

              {{user.name}}
              <i class="el-icon-arrow-down el-icon--right"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>个人信息</el-dropdown-item>
              <el-dropdown-item>gitub地址</el-dropdown-item>
              <el-dropdown-item @click.native='del()'>退出</el-dropdown-item>

            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </el-header>
      <el-main style="background-color:#eee">
       <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  name: 'HomeList',
  computed: {
    user () {
      return JSON.parse(sessionStorage.getItem('userinfo'))
    }
  },
  data () {
    return {
      isCollapse: false
    }
  },
  methods: {
    del () {
      this.$confirm('确定要退出吗, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        sessionStorage.removeItem('userinfo')
        this.$router.push('/login')
        this.$message({
          type: 'success',
          message: '退出成功!'
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消',
          duration: 1000
        })
      })
    },
    shou () {
      this.isCollapse ? this.isCollapse = false : this.isCollapse = true
    }
  }
}
</script>

<style lang="less" scoped>
.el-container {
  height: 100%;
  .el-aside{
    background:rgb(50, 55, 68);
    overflow: hidden;
  }
  .el-container {
    min-width: 800px;

    .el-header {
      padding: 0 9px 0 10px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      #right{
        width:40%;
        display: flex;
        align-items: center;
        .el-input{
          width: 40%
        }
        .el-dropdown-link{
         display: flex;
         align-items: center;
         div  {
          border-radius: 50%;
         overflow: hidden;

         }

        }
      }
    }
  }
}
</style>
